package com.train.classeval.controller;

import com.train.classeval.util.OSSUtil;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author Li.guoyong
 * @Group 教师组
 * @create 2021-09-18 19:08
 */
@RestController
@RequestMapping("/image")
public class UploadController {
    @PostMapping("upload")
    public ResponseEntity upload(MultipartFile file) throws IOException{
        String filename = file.getOriginalFilename();
        OSSUtil.upload(file.getInputStream(),"devimage/" + filename);
        String url = OSSUtil.getURL("devimage/" + filename);

        return ResponseEntity.ok(url);
    }
}
